package com.cy.pj.sys.Impl;

import com.cy.pj.sys.dao.SysNoticeDaoTest;
import com.cy.pj.sys.pojo.SysNotice;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;
import java.util.List;

@Component
//@Qualifier("SysNoticeImpl")
public class SysNoticeImpl implements SysNoticeDaoTest {

    private SysNotice sysNotice;

    @Autowired
    private SqlSession sqlSession;//默认注入的是SqlSessionTemplate，线程安全


    @Override
    public List<SysNotice> selectNotices(Long id) throws SQLException {
       // Class.forName()
        //获取接口包名
        String interfaceName = this.getClass().getInterfaces()[0].getName();
        System.out.println(interfaceName);
    //   String statement  ="com.cy.pj.notice.dao.SysNoticeDaoTest.selectNotices";
        String elementId1 = Thread.currentThread().getStackTrace()[0].getMethodName();
        //获取当前线程的方法栈，并取到当前方法的名字
        String elementId = Thread.currentThread().getStackTrace()[1].getMethodName();//获取当前方法名
        String statement  = interfaceName+"."+elementId;
        List<SysNotice> list = sqlSession.selectList(statement,id);
        return list;
    }

    @Override
    public int insertNotice(SysNotice sysNotice) {
        return 0;
    }

    @Override
    public int updateNotice(SysNotice sysNotice) {
        return 0;
    }

    @Override
    public int deleteNoticeList(Long... ids) {
        return 0;
    }

    @Override
    public SysNotice selectAnno(long id) {
        return null;
    }

    @Override
    public List<SysNotice> selectWhere(SysNotice sysNotice) {
        return null;
    }
}
